home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / Communications / Internet / TurboTCP 2.1 ƒ / TCL MiniTelnet source / CTelnetTerminal.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-04  |  3.9 KB  |  159 lines  |  [TEXT/MMCC]

  1. /*
  2. ** CTelnetTerminal.h
  3. **
  4. **    MiniTelnet application
  5. **    Telnet session document
  6. **
  7. **    Copyright © 1993-94, FrostByte Design / Eric Scouten
  8. **
  9. */
  10.  
  11.  
  12. #pragma once
  13.  
  14. #include "CDocument.h"
  15. #include "CFile.h"
  16. #include "CWindow.h"
  17.  
  18. #include "CTelnetInterp.h"
  19. #include "CTerminalPane.h"
  20. #include "MiniTelnet.const.h"
  21.  
  22.  
  23. // important resource numbers
  24.  
  25. #define MENUTelnet            21
  26. #define WINDTelnet            1026
  27. #define SCPNTelnet            1026
  28. #define DLOGSettings        2800
  29. #define STR_SettingsPrompt    2800
  30.  
  31.  
  32. // command numbers
  33.  
  34. #define cmdOpenSettings        2000L                // File menu
  35.  
  36. #define cmdSendSynch        2100L                // Telnet menu
  37. #define cmdSendBreak        2101L
  38. #define cmdSendAO            2102L
  39. #define cmdSendIP            2103L
  40. #define cmdSendAYT            2104L
  41. #define cmdSendGA            2105L
  42. #define cmdSendEC            2110L
  43. #define cmdSendEL            2111L
  44. #define cmdSendIPAddr        2120L
  45. #define cmdShowDebug        2199L
  46.  
  47. #define cmdSaveSettings        2800L                // Settings dialog
  48.  
  49.  
  50. /*______________________________________________________________________
  51. **
  52. ** CTelnetTerminal
  53. **
  54. **    This class implements the behavior of a terminal connected to Telnet. It uses the
  55. **    CTerminalPane class to draw the terminal screen. It handles all user events (such as
  56. **    key-downs) and interacts with CTCPStream to process them.
  57. **
  58. **    Some debugging methods are included so that the “behind-the-scenes” negotiation of
  59. **    Telnet can be viewed on-screen.
  60. **
  61. **    TurboTCP 2.0 changes: This class is a descendent of both CDocument and CTelnetInterp.
  62. **    It no longer bases off CTCPSessionDoc.
  63. **
  64. */
  65.  
  66. class CTelnetTerminal : public CDocument, public CTelnetInterp {
  67.  
  68.     TCL_DECLARE_CLASS;
  69.  
  70. protected:
  71.     CTerminalPane*    itsTerminal;                // terminal who displays our I/O
  72.     TelnetSettingsRec    r;                        // settings record
  73.     short            itsTermMode;                // which terminal emulation?
  74.  
  75.  
  76.     // constructor
  77.  
  78. public:
  79.                     CTelnetTerminal(unsigned short theDefaultPort,
  80.                         unsigned long recBufferSize = recReceiveSize,
  81.                         unsigned short autoReceiveSize = recAutoRecSize,
  82.                         unsigned short autoReceiveNum = recAutoRecNum,
  83.                         Boolean doUseCName = TRUE,
  84.                         Boolean printable = TRUE);
  85.  
  86.     // creating new sessions
  87.  
  88.     virtual void        NewSession(TelnetSettingsRec* theSettings);
  89.     virtual void        BuildWindow();
  90.  
  91.  
  92.     // closing windows & sessions
  93.  
  94.     virtual Boolean        Close(Boolean quitting);
  95.     virtual void        RemoteClose();
  96.  
  97.  
  98.     // window titling
  99.  
  100.     virtual void        SetWindowTitle(Str255 newTitle);
  101.     virtual void        GetFileName(Str255 theName)
  102.                         { if (itsFile) itsFile->GetName(theName); else theName[0] = '\0'; }
  103.     
  104.     // command/event handling
  105.  
  106.     virtual void        DoCommand(long theCommand);
  107.     virtual void        DoKeyDown(char theChar, Byte keyCode, EventRecord* macEvent);
  108.     virtual void        DoAutoKey(char theChar, Byte keyCode, EventRecord* macEvent)
  109.                         { DoKeyDown(theChar, keyCode, macEvent); }
  110.     virtual void        DoPaste();
  111.     virtual void        UpdateMenus();
  112.  
  113.  
  114.     // data handling methods
  115.  
  116.     virtual void        HandleNVTChar(uchar theChar)
  117.                         { itsTerminal->DoWriteChar(theChar); }
  118.     virtual void        HandleNVTLine(char* theLine)
  119.                         { itsTerminal->DoWriteStr(theLine); }
  120.  
  121.  
  122.     // Telnet command handling
  123.  
  124.     virtual void        ReceivedDo(uchar theOption);
  125.     virtual void        ReceivedAYT();
  126.     virtual void        ReceivedEC()
  127.                         { itsTerminal->DoEraseChar(); }
  128.     virtual void        ReceivedEL()
  129.                         { itsTerminal->DoEraseLine(); }
  130.     virtual void        ReceivedSE();
  131.  
  132.  
  133.     // Telnet option handling
  134.  
  135.     virtual void        OptionTerminalType();
  136.  
  137.  
  138.     // terminal emulation handling
  139.  
  140.     virtual void        GetTerminalName(short termIndex, char* termStr);
  141.  
  142.  
  143.     // debugging methods
  144.         // These methods were useful to me in debugging the implementation of various Telnet
  145.         // options. They are enabled by the “Show debugging codes” option of the settings dialog.
  146.  
  147.     virtual void        PrintDebugStr(char* theDebugStr)
  148.                         { itsTerminal->DoWriteStr(theDebugStr); }
  149.     virtual void        PrintDebugCharNum(char theChar, char leftBracket, char rightBracket)
  150.                         { itsTerminal->DoWriteCharNum(theChar, leftBracket, rightBracket); }
  151.  
  152.  
  153.     // CDocument methods which are not implemented here
  154.     
  155.     virtual void        NewFile() {};
  156.     virtual void        OpenFile(SFReply* macSFReply) {};
  157.  
  158. };
  159.